package com.rzjm.api.service.impl;

import com.rzjm.api.dao.SysErrorDao;
import com.rzjm.api.entity.SysError;
import com.rzjm.api.service.SysErrorService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

@Service
public class SysErrorServiceImpl extends BaseServiceImpl<SysErrorDao, SysError> implements SysErrorService {
    @Resource
    private SysErrorDao dao;

    @Override
    public int insertSelective(String name,Exception e) {

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        e.printStackTrace(new PrintStream(baos));
        String exception = baos.toString();

        SysError record = new SysError();
        record.setName(name);
        record.setErrorContent(exception);
        return dao.insert(record);
    }
}
